<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <p>Hello World</p>
    <div id="main">
        <p>The DOM is very useful.</p>
        <p>本例演示<b>getElementById</b>使用方法</p>
    </div>

    <script>
        var x = document.getElementById("main");
        var y = x.getElementsByTagName("p");
        document.write('id为“main”的div中的第一段文本是：' + y[1].innerHTML);
    </script>
</body>
</html>